package com.hxl.demo.service.Impl;

import com.hxl.demo.entity.Dept;
import com.hxl.demo.mapper.DeptMapper;
import com.hxl.demo.service.DeptService;
import com.hxl.demo.tools.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DeptServiceImpl implements DeptService {
    @Resource
    private DeptMapper deptMapper;

    @Override
    public List<Dept> selectAllDept() {
        //List<Dept> depts = deptMapper.selectAllDept();
        return null;
    }

    @Override
    public PageInfo<Dept> page(int begin, int limit, Dept dept) {
        int count = deptMapper.count(dept);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("begin", begin);
        map.put("limit", limit);
        map.put("dept", dept);
        PageInfo<Dept> pageInfo = new PageInfo<>();
        pageInfo.setTotal(count);
        pageInfo.setData(deptMapper.selectAllDept(map));
        return pageInfo;
    }
}
